Skip to main content

User Identification in Events

How to Cross-Reference Information to Identify the User

In many operational scenarios, identifying the user responsible for an event is essential for analysis, contextual actions, and auditing. Below, we list possible approaches to perform this identification based on secure technical practices compatible with privacy guidelines.

1 - Using notificationToken:

This function expects a String parameter, which represents the user's notification token. On iOS, this token is provided by APNS (Apple Push Notification Service), while on Android, it is obtained through Firebase Cloud Messaging.

After a regular configuration of the FCM on your project. Retrieve the Firebase token and set with the setFirebaseToken(Context context, String token) from the Grouplink class.


FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
Log.w(TAG, "Fetching FCM registration token failed", task.getException());
return;
}

// Get new FCM registration token
String token = task.getResult();
Context context = MainActivity.this;
// Log and toast
String msg = getString(R.string.msg_token_fmt, token);
Log.d(TAG, msg);
//Set the Firebase Token in the grouplink sdk.
Grouplink.setFirebaseToken(context, token);
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
});

The Firebase Token must be monitored, because it changes periodically. Do the same to the after a token is renewed.

/**
* There are two scenarios when onNewToken is called:
* 1) When a new token is generated on initial app startup
* 2) Whenever an existing token is changed
* Under #2, there are three scenarios when the existing token is changed:
* A) App is restored to a new device
* B) User uninstalls/reinstalls the app
* C) User clears app data
*/
override fun onNewToken(token: String) {
Log.d(TAG, "Refreshed token: " + token)
//Set the Firebase Token in the grouplink sdk.
Grouplink.setFirebaseToken(context, token)
super.onNewToken(token)
}

2 - Using notification_name:

This function expects a String parameter that represents the notification name associated with the device. This name is a customizable identifier you can use to manage or label notifications for a specific user or context.

We strongly recommend not using sensitive information in the notification_name. Instead, use unique identifiers that are properly encrypted or obfuscated. For example, using the user's session-id is a safer approach that helps ensure security and privacy when identifying devices.

Setting user notification_name:

class App : Application() {
override fun onCreate() {
super.onCreate()
...
GroupLink.setNotificationName(context, notificationName);
}
}

Getting the user notification_name:

class App : Application() {
override fun onCreate() {
super.onCreate()
...
String notificationName = GroupLink.getNotificationName(context);
}
}